package com.myosw.quartz;


import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.myosw.cache.common.SearchlogEhCache;
import com.myosw.dao.SearchlogDao;
import com.myosw.jdbc.common.DBManager;

public class SearchlogJob implements Job {

	private static Logger _log = LoggerFactory.getLogger(SearchlogJob.class);
	@Override
	public void execute(JobExecutionContext jobcontext) throws JobExecutionException {
		_log.info("**********"+jobcontext.getJobDetail().getKey().getName()+"执行搜索日志的存储");
		Object[][] objects=SearchlogEhCache.getlog();
		if (objects!=null) {
			SearchlogDao searchlogDao = new SearchlogDao();
			searchlogDao.save(objects);
			SearchlogEhCache.remove();
		}
		//关闭数据库链接
		DBManager.closeConnection(); //释放数据库连接到连接池中

	}

}
